<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <ul class="list">
        <li>6000</li>
        <li>4000</li>
        <li>2000</li>
        <li>1000</li>
    </ul>
    <ul class="list">
        <li>南山</li>
        <li>福田</li>
        <li>罗湖</li>
        <li>龙华</li>
    </ul>
    <ul class="list">
        <li>三房两厅</li>
        <li>两房一厅</li>
        <li>一房一厅</li>
        <li>独立单间</li>
    </ul>

    <h2>搜索结果：</h2>
    <ul class="search">

    </ul>
    <script>
        // 获取list
        let list = $(".list");

        // 获取搜索ul
        let search = $(".search")[0];
        console.log(search);

        for (let i = 0; i < list.length; i++) {
            add_search(list[i]);
        }

        function add_search(obj) {
            let lis = obj.querySelectorAll("li");
            let newLi = null;

            for (let i = 0; i < lis.length; i++) {
                lis[i].onclick = function() {
                    if (!newLi) {
                        // 克隆li
                        newLi = this.cloneNode(true);
                        search.appendChild(newLi);
                    } else {
                        newLi.innerHTML = this.innerHTML;
                    }
                }
            }
        }



        function $(select) {
            return document.querySelectorAll(select);
        }
    </script>
</body>

</html>